package com.es.hr.baoxiaoShenpi;

import java.lang.reflect.Field;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBean;
import com.es.business.area.AreaBiz;
import com.es.business.city.CityBean;
import com.es.business.city.CityBiz;
import com.es.business.citys.CitysBean;
import com.es.business.citys.CitysBiz;
import com.es.business.province.ProvinceBean;
import com.es.business.province.ProvinceBiz;
import com.es.common.CommonBean;
import com.es.common.CommonBiz;
import com.es.hr.baoxiao.BaoxiaoBean;
import com.es.hr.baoxiao.BaoxiaoBiz;
import com.es.hr.emp.EmpInfoBean;
import com.es.main.LoginUserBeen;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class SearchCTMBaoxiaoDoAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		String message = "";
		BaoxiaoShenpiBiz baoxiaoShenpiBiz = new BaoxiaoShenpiBiz();
		BaoxiaoBiz baoxiaoBiz = new BaoxiaoBiz();
		
		LoginUserBeen userLogin = (LoginUserBeen)request.getSession().getAttribute("loginuser");
		String role = userLogin.getLoginRole();
		BaoxiaoBean bean = baoxiaoBiz.getBaoxiaoBaseInfoFromEmp(userLogin.getLoginId());
		
		String baoxiao_starttime = this.request.getParameter("baoxiao_starttime").trim();
		this.request.setAttribute("baoxiao_starttime", baoxiao_starttime);
		String baoxiao_endtime = this.request.getParameter("baoxiao_endtime").trim();
		this.request.setAttribute("baoxiao_endtime", baoxiao_endtime);
		String baoxiao_state = this.request.getParameter("baoxiao_state");
		this.request.setAttribute("baoxiao_state", baoxiao_state);
		int curpage = this.request.getParameter("curpage") == null?1:new Integer(this.request.getParameter("curpage")).intValue();
		this.request.setAttribute("curpage", curpage);
		this.request.setAttribute("baoxiaoStateList",  new CommonBiz().getCommonByType("baoxiaostate"));
		CommonBean shiyebu = new CommonBiz().getCommonByTypeAndCode("shiyebu", "ITMall");
		
		//只有事业部itmall的ctm才能申请报销
		if(role.equals("CTM") && userLogin.getShiyebu().equals(shiyebu.getCommonValue())){
			PageBean res = baoxiaoShenpiBiz.searchCTMBaoxiao( bean.getCtm_code(),baoxiao_starttime,baoxiao_endtime,baoxiao_state, curpage);
			this.request.setAttribute("pageBean", res);
			result = "success";
			return result;
		}else{
			 message = "只有ITMall的CTM才能执行该操作！";
			this.request.setAttribute("message", message);
			return "error";
		}
	}

}
